package com.wd.elec.utils;



import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;

/**
 * @className: FileUtils
 * @description: TODO 类描述
 * @author: liumingkun
 * @date: 2024/7/19
 **/
public class FileUtils {
    public static void main(String[] args) {

    }
    public static String readFile(String uploadPath,String fileName){
        StringBuilder stringBuilder=new StringBuilder();
        File file;
        if (CommonUtil.isOSLinux()) {
            file = new File(uploadPath + fileName);
        } else {
            file = new File(System.getProperty("user.dir") + uploadPath + fileName);
        }
        try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
            String line;
            // 逐行读取并输出到控制台
            while ((line = reader.readLine()) != null) {
                stringBuilder.append(line);
            }

        } catch (IOException e) {
            e.printStackTrace();
        }
        return stringBuilder.toString();
    }
}
